﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using FaceRecognition.Models;

namespace FaceRecognition.View
{
    public partial class Form_Session : Form
    {
        private Form_Login form_Login;
        
        Controller.Accounts_manager AM = new Controller.Accounts_manager();
        User_Manager Obj_UserManager = new User_Manager();
        public Form_Session(Form_Login form_login_temp)
        {
            InitializeComponent();
            this.form_Login = form_login_temp;
            Singleton.Get_Instance();
            label1.Text = Singleton.Get_Email();
        }
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            base.OnFormClosing(e);
            form_Login.Show();
            Singleton.End_Session();
            this.Dispose();
            if (e.CloseReason == CloseReason.WindowsShutDown)
            {
                return;
            }

            // Confirm user wants to close
            //switch (MessageBox.Show(this, "Are you sure you want to close?", "Closing", MessageBoxButtons.YesNo))
            //{
            //    case DialogResult.No:
            //        e.Cancel = true;
            //        break;
            //    default:
            //        break;
            //}
        }

        private void button_sign_out_Click(object sender, EventArgs e)
        {
            form_Login.Show();
            Singleton.End_Session();
            this.Dispose();
        }

        private void Form_Session_Load(object sender, EventArgs e)
        {
            
            int user_id=Obj_UserManager.ID_retrival_by_email(Singleton.Get_Email());
            List<string> urls = new List<string>();
            urls = AM.retreive_all_Url(user_id);
            for (int i = 0; i < urls.Count; i++)
            {
                listBox1.Items.Add(urls[i]);
            }
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //Obj_UserManager.ID_retrival_by_email(Singleton.Get_Email());
            Form_AddAccount form_add_account = new Form_AddAccount();
            form_add_account.Show();
        }

        private void button3_Click(object sender, EventArgs e)
        {

        }

        private void button4_Click(object sender, EventArgs e)
        {
            Form_DeleteAccount form_delete_account = new Form_DeleteAccount();
            form_delete_account.Show();
        }

    
    }
}
